package com.naiterui.ehp.bs.consult.controller.inner;

import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.support.exception.BaseExceptionCodes;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bs.consult.util.TrtcUtil;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author luao
 * @date 2022/4/21 10:38 AM
 **/
@Api(tags = {SwaggerTag.VIDEO + SwaggerTag.INNER_API + SwaggerTag.SELF_INSPECT})
@RestController
@RequestMapping("inner/self/inspect")
@RequiredArgsConstructor
public class InnerSelfInspectController {

    @ApiOperation(value = "腾讯云实时音视频自检")
    @GetMapping("/trtc")
    public void trtcCheck() throws BusinessException {
        try {
            long time = System.currentTimeMillis() / 1000;
            TrtcUtil.describeRoomInformation(time, time);
        } catch (TencentCloudSDKException e) {
            e.printStackTrace();
            throw new BusinessException(BaseExceptionCodes.FAILED, "腾讯云实时音视频自检失败 msg:{}" + e.getMessage());
        }
    }
}
